// forcetalk.txt
// Liek alknpc, but this character will aprroach and speak with character first time.
// Memory Cells:
//   Cell 0 - If 0, default behavior. If 1, it doesnt fidget.
//   Cell 1 - Number of state when talked to. Plays default text if 0.
//   Cell 2,3 -  Stuff done flag. if it is 0, this character hunts party down
//   Cell 4 - Speaking range. Range pc is within to hunt down. Default to 12.
begincreaturescript;

variables;

short i,target;
short has_greeted = 0;
short speak_range = 12;

body;

beginstate INIT_STATE;
	if (get_memory_cell(4) > 0)
		speak_range = get_memory_cell(4);
	break;

beginstate DEAD_STATE;
break;

beginstate START_STATE;
	// if I have a target for some reason, go attack it
	if (target_ok()) {
		set_state(3);
		}
	
	if (get_foe_target(ME,8,0)) {
		do_attack();
		set_state(3);
		}
	if (who_shot_me() >= 0) { 
		set_foe_target(ME,who_shot_me());
		do_attack();
		set_state(3);
		}
	if (gf(78,9) > 0) {
		if (dist_to_nav_point(ME,1) >= 2) {
			approach_nav_point(ME,1,2);
			}
			else fidget(ME,15);
		}
		
	if ((dist_to_pc() < 50) && (get_flag(get_memory_cell(2),get_memory_cell(3)) == 0)) {
		approach_char(ME,pc_num(),1);
		set_state(4);
		}



break;

beginstate 3; // attacking
	if (target_ok() == FALSE)
		set_state(START_STATE);
	do_attack();
break;

beginstate 4; // approaching pc
	if (get_flag(get_memory_cell(2),get_memory_cell(3)) > 0)
		set_state(START_STATE);
	if (get_attitude(ME) >= 10) {
		set_state(START_STATE);
		}
	if ((approach_char(ME,pc_num(),1)) || (dist_to_pc() <= 4)) {
		set_flag(get_memory_cell(2),get_memory_cell(3),1);
		begin_talk_mode(get_memory_cell(1));
		}
break;


beginstate TALKING_STATE;
	if (get_memory_cell(1) == 0) {
		print_str("Talking: You make a bit of small talk, but you don't learn");
		print_str("  anything interesting.");
		}
		else begin_talk_mode(get_memory_cell(1));
break;